@include('admin.header')
<style type="text/css">
.pic-list li {
	margin-bottom: 5px;
}
</style>
</head>
<body>
	<div class="wrap js-check-wrap">
		<ul class="nav nav-tabs">
			<li><a href="/mobile/agent">区域代理</a></li>
			<li  class="active"><a href="javascript:void(0)" target="_self">编辑</a></li>
		</ul>
		<form method="post" id="add" class="form-horizontal js-ajax-forms" enctype="multipart/form-data">
			<div class="row-fluid">
				<table class="table table-bordered">
					<input type="hidden" name="id" value="{{$data->id or 0}}"/>
					<tr>
						<th width="100">ID</th>
						<td>{{$data->id or 0}}</td>
					</tr>
					<tr>
						<th width="100">申请人</th>
						<td>{{$data->nodename or ''}}</td>
					</tr>
					<tr>
						<th>区域代理名称</th>
						<td>
							<input type="text" style="width:400px;" name="name"  value="{{$data->name or '' }}" placeholder="请输入区域代理名称"/>
						</td>
					</tr>
					<tr>
						<th>地区</th>
						<td>{{$data->region_name or '' }}</td>
					</tr>
					<tr>
						<th>详细地址</th>
						<td><input type="text" name="address"  value="{{$data->address or '' }}" style="width: 400px" placeholder="请输入详细地址"></td>
					</tr>
					<tr>
						<th>状态</th>
						<td>
							<select id="cate_id"  name="cate_id">
								<option value="1">正常</option>
								<option value="0">禁用</option>
							</select>
						</td>
					</tr>
					<tr>
						<th>备注摘要</th>
						<td>
							<textarea name="remarks" style="width: 98%; height: 50px;" placeholder="请填写摘要">{{$data->remarks or '' }}</textarea>
						</td>
					</tr>
				</table>
			</div>
			<div class="form-actions">
				<input type="hidden" name="_token"  value="{{csrf_token()}}"/>
				<button class="btn btn-primary js-ajax-submit" type="submit">提交</button>
				<a class="btn" href="{{asset('mobile/index')}}">返回</a>
			</div>
		</form>
	</div>
	<script type="text/javascript" src="/static/js/common.js"></script>
	<script type="text/javascript" src="/static/js/validate/validate.js"></script>
	<script type="text/javascript" src="/static/js/layer/layer.js"></script>
	<script type="text/javascript" src="/static/js/ajaxfileupload.js"></script>
	<script type="text/javascript">
		$(function() {
			$("#add").validate({
				rules: {
					name: {
						required: true
					}
				},
				messages: {
					name: {
						required: "区域代理名称不能为空"
					}
				},
				submitHandler: function () {
					var data = {
						_token : $('input[name=_token]').val(),
						id : $('input[name=id]').val(),
						name :  $("input[name=name]").val(),
						address : $('input[name=address]').val(),
						status : $("select option:selected").val(),
						remarks : $('textarea[name=remarks]').val(),
					}
					$.post("/mobile/agent_edit",data, function (msg) {
						if (msg.status == 1) {
							layer.confirm(msg.info, {
								btn: ['确定']
							}, function(){
								window.location.href="{{asset('mobile/agent')}}";
							});
						} else {
							showMsg(msg.info);
							return false;
						}
					}, 'json');
				}
			});
		});
		/**
		 * layer提示
		 */
		function showMsg(msg){
			layer.alert(msg, {
				title: '提示',
				icon: 2,
			});
		}
	</script>
</body>
</html>